local sk__liangyuan = fk.CreateSkill {

  name = "sk__liangyuan",

  tags = { Skill.Limited, },

}



sk__liangyuan:addEffect("active", {
  name = "sk__liangyuan",
  anim_type = "support",
  prompt = "#sk__liangyuan",
  card_num = 0,
  target_num = 1,
  can_use = function(self, player)
    return player:usedSkillTimes(sk__liangyuan.name, Player.HistoryGame) == 0
  end,
  target_filter = function(self, player, to_select, selected, selected_cards)
    return #selected == 0 and to_select ~= player and to_select.gender == General.Male
  end,
  card_filter = Util.FalseFunc,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    room:setPlayerMark(player, "@sk__liangyuan", target.general)
    room:setPlayerMark(player, sk__liangyuan.name, target.id)
  end,
})

sk__liangyuan:addEffect(fk.TurnEnd, {
  name = "#sk__liangyuan_delay",
  mute = true,
  events = { fk.TurnEnd },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:usedSkillTimes("sk__liangyuan", Player.HistoryGame) > 0 and
        not player:insideExtraTurn() and not player.room:getPlayerById(player:getMark("sk__liangyuan")).dead
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    player.room:getPlayerById(player:getMark("sk__liangyuan")):gainAnExtraTurn(true, "sk__liangyuan")
  end,
})

return sk__liangyuan
